<template>
    <view>
        <!--标题和返回-->
		<cu-custom :bgColor="NavBarColor" isBack :backRouterName="backRouteName">
			<block slot="backText">返回</block>
			<block slot="content">车辆表</block>
		</cu-custom>
		 <!--表单区域-->
		<view>
			<form>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">用户：</text></view>
                  <input  placeholder="请输入用户" v-model="model.userId"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">用户手机号：</text></view>
                  <input  placeholder="请输入用户手机号" v-model="model.userPhone"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">行驶证：</text></view>
                  <input  placeholder="请输入行驶证" v-model="model.drivingLicense"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">车辆识别代号：</text></view>
                  <input  placeholder="请输入车辆识别代号" v-model="model.drivingFVin"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">住址：</text></view>
                  <input  placeholder="请输入住址" v-model="model.drivingFAddr"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">发证日期：</text></view>
                  <input  placeholder="请输入发证日期" v-model="model.drivingFPubDate"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">发证单位：</text></view>
                  <input  placeholder="请输入发证单位" v-model="model.drivingFPubOrg"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">品牌型号：</text></view>
                  <input  placeholder="请输入品牌型号" v-model="model.drivingFBrandModel"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">所有人：</text></view>
                  <input  placeholder="请输入所有人" v-model="model.drivingFAny"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">使用性质：</text></view>
                  <input  placeholder="请输入使用性质" v-model="model.drivingFUseProperty"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">发动机号码：</text></view>
                  <input  placeholder="请输入发动机号码" v-model="model.drivingFEngineNo"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">号牌号码：</text></view>
                  <input  placeholder="请输入号牌号码" v-model="model.drivingFVehicleNo"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">注册日期：</text></view>
                  <input  placeholder="请输入注册日期" v-model="model.drivingFRegDate"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">检验记录：</text></view>
                  <input  placeholder="请输入检验记录" v-model="model.drivingBCheckRecord"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">核定载质量：</text></view>
                  <input  placeholder="请输入核定载质量" v-model="model.drivingBVgwr"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">整备质量：</text></view>
                  <input  placeholder="请输入整备质量" v-model="model.drivingBCurbWeight"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">外廓尺寸：</text></view>
                  <input  placeholder="请输入外廓尺寸" v-model="model.drivingBLwh"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp"> 核定载人数：</text></view>
                  <input  placeholder="请输入 核定载人数" v-model="model.drivingBPax"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">总质量：</text></view>
                  <input  placeholder="请输入总质量" v-model="model.drivingBGvs"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">燃油类型：</text></view>
                  <input  placeholder="请输入燃油类型" v-model="model.drivingBFuelType"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">准牵引总质量：</text></view>
                  <input  placeholder="请输入准牵引总质量" v-model="model.drivingBGcwr"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">备注：</text></view>
                  <input  placeholder="请输入备注" v-model="model.drivingBRemark"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">档案编号：</text></view>
                  <input  placeholder="请输入档案编号" v-model="model.drivingBDocNo"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">号牌号码：</text></view>
                  <input  placeholder="请输入号牌号码" v-model="model.drivingBVehicleNo"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">证芯编号：</text></view>
                  <input  placeholder="请输入证芯编号" v-model="model.drivingBCcn"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">道路运输证：</text></view>
                  <input  placeholder="请输入道路运输证" v-model="model.roadTransportCertificate"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">道路运输证号：</text></view>
                  <input  placeholder="请输入道路运输证号" v-model="model.roadNo"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">车牌号码：</text></view>
                  <input  placeholder="请输入车牌号码" v-model="model.roadVehicleNo"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">经济类型：</text></view>
                  <input  placeholder="请输入经济类型" v-model="model.roadEconType"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">经营范围：</text></view>
                  <input  placeholder="请输入经营范围" v-model="model.roadBusiRange"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">车辆类型：</text></view>
                  <input  placeholder="请输入车辆类型" v-model="model.roadVehicleType"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">吨座位：</text></view>
                  <input  placeholder="请输入吨座位" v-model="model.roadTon"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">备注：</text></view>
                  <input  placeholder="请输入备注" v-model="model.roadRemark"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">经营许可证号：</text></view>
                  <input  placeholder="请输入经营许可证号" v-model="model.roadBusiPermitNo"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">车辆毫米_高：</text></view>
                  <input  placeholder="请输入车辆毫米_高" v-model="model.roadVehicleMmHeight"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">车辆毫米_宽：</text></view>
                  <input  placeholder="请输入车辆毫米_宽" v-model="model.roadVehicleMmWeight"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">车辆毫米_长：</text></view>
                  <input  placeholder="请输入车辆毫米_长" v-model="model.roadVehicleMmLong"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">发证日期：</text></view>
                  <input  placeholder="请输入发证日期" v-model="model.roadPubDate"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">地址：</text></view>
                  <input  placeholder="请输入地址" v-model="model.roadAddr"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">业户名称：</text></view>
                  <input  placeholder="请输入业户名称" v-model="model.roadUserName"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">初领日期：</text></view>
                  <input  placeholder="请输入初领日期" v-model="model.roadFirstDate"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">车辆状态：</text></view>
                  <input  placeholder="请输入车辆状态" v-model="model.vehicleStatus"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">状态：</text></view>
                  <input  placeholder="请输入状态" v-model="model.status"/>
                </view>
              </view>
				<view class="padding">
					<button class="cu-btn block bg-blue margin-tb-sm lg" @click="onSubmit">
						<text v-if="loading" class="cuIcon-loading2 cuIconfont-spin"></text>提交
					</button>
				</view>
			</form>
		</view>
    </view>
</template>

<script>
    import myDate from '@/components/my-componets/my-date.vue'

    export default {
        name: "WlhyVehicleForm",
        components:{ myDate },
        props:{
          formData:{
              type:Object,
              default:()=>{},
              required:false
          }
        },
        data(){
            return {
				CustomBar: this.CustomBar,
				NavBarColor: this.NavBarColor,
				loading:false,
                model: {},
                backRouteName:'index',
                url: {
                  queryById: "/vehicle/wlhyVehicle/queryById",
                  add: "/vehicle/wlhyVehicle/add",
                  edit: "/vehicle/wlhyVehicle/edit",
                },
            }
        },
        created(){
             this.initFormData();
        },
        methods:{
           initFormData(){
               if(this.formData){
                    let dataId = this.formData.dataId;
                    this.$http.get(this.url.queryById,{params:{id:dataId}}).then((res)=>{
                        if(res.data.success){
                            console.log("表单数据",res);
                            this.model = res.data.result;
                        }
                    })
                }
            },
            onSubmit() {
                let myForm = {...this.model};
                this.loading = true;
                let url = myForm.id?this.url.edit:this.url.add;
				this.$http.post(url,myForm).then(res=>{
				   console.log("res",res)
				   this.loading = false
				   this.$Router.push({name:this.backRouteName})
				}).catch(()=>{
					this.loading = false
				});
            }
        }
    }
</script>
